<template>
    <base-breadcrumb>
        <a-row :gutter="10">
            <a-col>
                <searchData :searchData="searchArr" @search="handleSearch"></searchData>
                <a-card class="mb20">
                    <div class="pub-table-action-btn">
                        <!--<a-button icon="download" type="primary">导出</a-button>-->
                    </div>
                    <!--a-table多选-->
                    <!--<div class="pub-table-select-count">-->
                    <!--<a-icon type="info-circle" theme="twoTone"/>已选择{{ chooseData }}项-->
                    <!--</div>-->
                    <!--:row-selection="{onChange: onSelectChange }"-->
                    <a-table :pagination="pagination" :columns="columns" :data-source="tableData" row-key="id">
                        <template slot="operation" slot-scope="text, record">
                            <div class="pub-table-list-action">
                                <span @click="handleModel(record)">授权</span>
                            </div>
                        </template>
                        <template slot="accountType" slot-scope="text, record">
                            <span v-if="record.accountType == 0">永久账号</span>
                            <span v-if="record.accountType == 1">临时账号</span>
                        </template>
                        <template slot="state" slot-scope="text, record">
                            <span v-if="record.state == 0">启用</span>
                            <span v-if="record.state == 1">未审核</span>
                            <span v-if="record.state == 2">驳回</span>
                            <span v-if="record.state == 3">休眠</span>
                            <span v-if="record.state == 4">锁定</span>
                            <span v-if="record.state == 5">禁用</span>
                            <span v-if="record.state == 6">冻结</span>
                        </template>
                    </a-table>
                </a-card>
            </a-col>
        </a-row>
        <JurisdictionUpdate :visible="visible" :record="record" @handleCancel="handleCancel"></JurisdictionUpdate>
    </base-breadcrumb>
</template>

<script>
import { searchArr, columns } from './model'
import JurisdictionUpdate from './jurisdictionUpdate'
import { getjurisdictionList, getPointDomains, deleteRoleList } from '@/api/system/system'
export default {
    name: 'jurisdictionManage',
    components: {
        JurisdictionUpdate,
    },
    data() {
        return {
            //密码重置
            visible: false,
            formModelData: {},
            searchArr: searchArr,
            columns: columns,
            chooseData: 0,
            tableData: [],
            roleIndex: 1,
            record: {},

            pagination: {
                defaultCurrent: 1, // 默认当前页数
                defaultPageSize: 10, // 默认当前页显示数据的大小
                total: 0, // 总数，必须先有
                showSizeChanger: true,
                showQuickJumper: true,
                pageSizeOptions: ['10', '20', '40', '100'],
                showTotal: (total) => `共 ${total} 条`, // 显示总数
                onShowSizeChange: (current, pageSize) => {
                    this.pagination.defaultCurrent = 1
                    this.pagination.defaultPageSize = pageSize
                    this.handleSearch()
                },
                // 改变每页数量时更新显示
                onChange: (current, size) => {
                    this.pagination.defaultCurrent = current
                    this.pagination.defaultPageSize = size
                    this.handleSearch()
                },
            },
        }
    },
    created() {
        this.handleSearch()
    },
    mounted() {},
    methods: {
        /**
         *@desc  table表格搜索
         *@param {}
         */
        handleSearch(val) {
            this.handleTable(val)
        },
        /**
         *@desc  table表格列表 获取
         *@param {}
         */
        handleTable(params) {
            let _this = this
            let searchData = {
                state: 0,
                pageNum: _this.pagination.defaultCurrent,
                pageSize: _this.pagination.defaultPageSize,
                ...params,
            }
            getjurisdictionList(searchData).then((res) => {
                if (res.status === 200) {
                    _this.pagination.total = res.data.total
                    _this.tableData = res.data.list
                }
            })
        },
        /**
         *@desc  table表格选中
         *@param {}
         */
        onSelectChange(selectedRowKeys, selectedRows) {
            let _this = this
            _this.selectId = []
            selectedRows.map((item) => {
                // 选中id
                _this.selectId.push(item.id)
            })
            this.chooseData = this.chooseData + selectedRows.length
        },
        /**
         *@desc  table新增和编辑
         *@param {}
         */
        handleModel(record) {
            this.visible = true
            this.record = record
        },
        /**
         *@desc  table新增和编辑
         *@param {}
         */
        handleCancel() {
            this.visible = false
            this.handleSearch()
        },
    },
}
</script>

